//
//  AllTableViewCell.m
//  Cat
//
//  Created by dllo on 15/11/30.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "AllTableViewCell.h"

@implementation AllTableViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backView = [[UIView alloc] init];
        [self.contentView addSubview:self.backView];
        
        self.headerImageView = [[UIImageView alloc] init];
        [self.backView addSubview:self.headerImageView];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.backView addSubview:self.nameLabel];
        
        self.numberLabel = [[UILabel alloc] init];
        [self.backView addSubview:self.numberLabel];
        
        self.AllLabel = [[UILabel alloc] init];
        [self.backView addSubview:self.AllLabel];
        
        self.wordLabel = [[UILabel alloc] init];
        [self.backView addSubview:self.wordLabel];
        
        
    }
    return self;
}

- (void)layoutSubviews {
    self.contentView.backgroundColor = [UIColor colorWithRed:245 / 255.0 green:245 / 255.0 blue:245 / 255.0 alpha:1];
    self.backView.backgroundColor = [UIColor whiteColor];
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.top.equalTo(self.contentView.mas_top).with.offset(5);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-5);
    }];
    
    [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(10);
        make.top.equalTo(self.contentView.mas_top).with.offset(10);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-10);
        make.width.mas_equalTo(VIEW_WIDTH / 3);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerImageView.mas_right).with.offset(10);
        make.width.mas_equalTo(VIEW_WIDTH / 2);
        make.height.mas_equalTo(30);
        make.top.equalTo(self.contentView.mas_top).with.offset(10);
    }];
    
    [self.AllLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).with.offset(5);
        make.height.mas_equalTo(20);
        make.left.equalTo(self.headerImageView.mas_right).with.offset(5);
        make.width.mas_equalTo(40);
    }];
    self.AllLabel.layer.borderWidth = 1;
    self.AllLabel.layer.borderColor = [UIColor redColor].CGColor;
    self.AllLabel.layer.cornerRadius = 10;
    self.AllLabel.text = @"合集";
    self.AllLabel.textColor = [UIColor redColor];
    self.AllLabel.textAlignment = 1;
    self.AllLabel.font = [UIFont systemFontOfSize:15];
    
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.AllLabel.mas_right).with.offset(5);
        make.width.mas_equalTo(VIEW_WIDTH / 2);
        make.height.mas_equalTo(20);
        make.top.equalTo(self.nameLabel.mas_bottom).with.offset(5);
    }];
    self.numberLabel.font = [UIFont systemFontOfSize:15];
    
    [self.wordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(VIEW_WIDTH / 2);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-10);
        make.left.equalTo(self.headerImageView.mas_right).with.offset(5);
        make.top.equalTo(self.AllLabel.mas_bottom).with.offset(5);
    }];
    self.wordLabel.numberOfLines = 0;
    self.wordLabel.font = [UIFont systemFontOfSize:15];
    
}

- (void)setModel:(HotModel *)model {
    
    // 个人信息
    [ToolNetWorking ToolNetWorking:[NSString stringWithFormat:@"http://user.huapipi.com/userinfo/basic.do?uid=%@", model.uid] block:^(id result) {
        self.nameLabel.text = [NSString stringWithFormat:@"%@", result[@"nickname"]];
        [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:result[@"portrait"]] placeholderImage:[UIImage imageNamed:@"ooopic_1445565008@2x.png"]];
    }];
    
}

@end
